<?php
/**
 * User: hjd-yao
 * Date: 2019/4/30
 * Time: 17:19
 */

Route::get('/')->uses('IndexController@index')->name('f_Shop_index')->middleware('UserloginData');;

Route::post('upload-img')->uses('UploadController@uploadBase64')->name('f_Upload_uploadBase64')->middleware('CheckUserLogin');

Route::namespace('Wap')->prefix('m')->middleware('UserloginData')->group(function (){

    Route::get('classify')->uses('GoodsController@classify')->name('f_Wap_Goods_classify')->middleware('CheckUserLogin');;
    Route::get('search')->uses('GoodsController@search')->name('f_Wap_Goods_search')->middleware('CheckUserLogin');;

    Route::get('goods/{zone?}')->uses('GoodsController@goodsList')->name('f_Wap_Goods_goodsList')
        ->where('zone','1|2|3|4')->middleware('CheckUserLogin');;

    Route::get('detail')->uses('GoodsController@goodsDetail')->name('f_Wap_Goods_goodsDetail');

    Route::match(['post','get'],'get_goods_spec')->uses('GoodsController@GetGoodsSpec')->name('f_Wap_Goods_get_spec');

    Route::match(['post','get'],'art-detail')->uses('ArticleController@articleDetail')->name('f_Wap_Article_Detail');

    Route::match(['post','get'],'art-index')->uses('ArticleController@index')->name('f_Wap_Article_Index');

    Route::match(['post','get'],'art-all')->uses('ArticleController@articleAll')->name('f_Wap_Article_All');

    Route::match(['post','get'],'art-all-info/{cat_id}')->uses('ArticleController@articleAllInfo')->name('f_Wap_Article_AllInfo')
        ->where('cat_id','[0-9]+');

    Route::middleware('CheckUserLogin')->group(function (){
        /*购物车*/
        Route::get('cart/{zone?}')->uses('CartController@index')->name('f_Wap_Cart_index')
            ->where('zone','1|2|3|4');
        Route::post('cart-add')->uses('CartController@create')->name('f_Wap_Cart_create');
        Route::post('cart-edit/{cart_id}')->uses('CartController@update')->name('f_Wap_Cart_update')
            ->where('cart_id','[0-9]+');
        Route::match(['post','get'],'cart-remove')->uses('CartController@delete')->name('f_Wap_Cart_delete');

        /*订单*/
        Route::post('order-buy')->uses('OrderController@buyOrder')->name('f_Wap_Order_buyOrder');

        Route::post('cart-buy/{zone?}')->uses('OrderController@buyCart')->name('f_Wap_Order_buyCart')
            ->where('zone','1|2|3|4');//通过购物车购买

        Route::post('order-submit/{zone?}')->uses('OrderController@submitOrder')->name('f_Wap_Order_submitOrder')
            ->where('zone','1|2|3|4');//通过购物车购买

        Route::match(['post','get'],'order-pay/{order_id}')->uses('OrderController@payOrder')->name('f_Wap_Order_payOrder')
            ->where('order_id','[0-9]+');

        Route::get('order-wait-pay')->uses('OrderController@waitPayOrder')->name('f_Wap_Order_waitPayOrder');

        Route::match(['post','get'],'order-online-pay')->uses('OrderController@onlinePayOrder')->name('f_Wap_Order_onlinePayOrder');

        Route::match(['post','get'],'order-online-pay/{order_id}')->uses('OrderController@onlinePayOrder')->name('f_Wap_Order_onlinepayOrder')
            ->where('order_id','[0-9]+');

        Route::get('order-record')->uses('OrderController@orderRecord')->name('f_Wap_Order_orderRecord');
        Route::get('order-remove')->uses('OrderController@deleteOrder')->name('f_Wap_Order_deleteOrder');
        Route::get('order-confirm')->uses('OrderController@confirmOrder')->name('f_Wap_Order_confirmOrder');

        Route::get('order-detail')->uses('OrderController@detailOrder')->name('f_Wap_Order_detailOrder');

        /*我的*/
        Route::get('user')->uses('UserController@index')->name('f_Wap_User_index');
        Route::get('user/share')->uses('UserController@shareCode')->name('f_Wap_User_shareCode');
        Route::get('user/flow')->uses('UserController@accountFlow')->name('f_Wap_User_accountFlow');
        Route::get('user/bonus')->uses('UserController@bonusCount')->name('f_Wap_User_bonusCount');
        Route::get('user/team')->uses('UserController@myTeam')->name('f_Wap_User_myTeam');

        Route::match(['post','get'],'user/register')->uses('UserController@AddUser')->name('f_Wap_User_register');

        //阅读签到
        Route::match(['post','get'],'user/qiandao')->uses('UserController@qiandao')->name('f_Wap_User_qiandao');

        Route::get('user/active-list')->uses('UserController@ActiveUserList')->name('f_Wap_User_active_list');

        Route::get('user/active')->uses('UserController@ActiveUser')->name('f_Wap_User_active');

        Route::get('user/remove')->uses('UserController@removeUser')->name('f_Wap_User_remove');

        Route::match(['post','get'],'user/up-level')->uses('UserController@upUserLevel')->name('f_Wap_User_up_level');

        Route::match(['post','get'],'user/change-pwd/{action?}')->uses('UserController@updatePwd')
            ->name('f_Wap_User_updatePwd')->where('action','safe|login');


        Route::match(['post','get'],'user/edit')->uses('UserController@updateInfo')->name('f_Wap_User_updateInfo');

        Route::match(['post','get'],'user/collection')->uses('UserController@updateCollection')->name('f_Wap_User_updateCollection');

        Route::match(['post','get'],'user/certification')->uses('UserController@updateCertification')->name('f_Wap_User_updateCertification');

        Route::get('management')->uses('UserController@management')->name('f_Wap_User_management');

        Route::get('my-info')->uses('UserController@myInfo')->name('f_Wap_User_my_info');

        /*账号*/
        Route::get('account/rg-record')->uses('AccountController@rgRecord')->name('f_Wap_Account_rgRecord');

        Route::match(['post','get'],'account/recharge')->uses('AccountController@rgApply')->name('f_Wap_Account_rgApply');

        Route::get('account/wd-record')->uses('AccountController@wdRecord')->name('f_Wap_Account_wdRecord');
        Route::match(['post','get'],'account/cash-out')->uses('AccountController@wdApply')->name('f_Wap_Account_wdApply');

        // 账户互转
        Route::get('account/tf-record')->uses('AccountController@tfRecord')->name('f_Wap_Account_tfRecord');
        Route::match(['post','get'],'account/transfer')->uses('AccountController@transfer')->name('f_Wap_Account_transfer');

        /*地址管理*/
        Route::get('address')->uses('AddressController@myAddress')->name('f_Wap_Address_myAddress');
        Route::match(['post','get'],'address-add')->uses('AddressController@create')->name('f_Wap_Address_create');
        Route::match(['post','get'],'address-edit-{addr_id}')->uses('AddressController@update')->name('f_Wap_Address_update')
            ->where('addr_id','[0-9]+');

        Route::get('address-remove-{addr_id}')->uses('AddressController@delete')->name('f_Wap_Address_delete')
            ->where('addr_id','[0-9]+');

        Route::get('address-default-{addr_id}')->uses('AddressController@setDefault')->name('f_Wap_Address_setDefault')
            ->where('addr_id','[0-9]+');

        /*代售*/
        Route::get('agent-sales')->uses('AgentController@agentSales')->name('f_Wap_Agent_agentSales');

        Route::get('agent-me')->uses('AgentController@myAgent')->name('f_Wap_Agent_myAgent');

        Route::match(['post','get'],'consume-agent')->uses('AgentController@xfAgent')->name('f_Wap_Agent_xfAgent');
        Route::match(['post','get'],'exchange-agent')->uses('AgentController@dhAgent')->name('f_Wap_Agent_dhAgent');


        /*升级*/
        Route::match(['post','get'],'upgrade-index')->uses('UpgradeController@index')->name('f_Wap_Upgrade_index');
        Route::match(['post','get'],'upgrade-apply')->uses('UpgradeController@apply')->name('f_Wap_Upgrade_apply');
        Route::match(['post','get'],'upgrade-apply-record')->uses('UpgradeController@applyRecord')->name('f_Wap_Upgrade_apply_record');

        Route::match(['post','get'],'upgrade-apply-match-detail')->uses('UpgradeController@applyMatchDetail')->name('f_Wap_Upgrade_apply_match_detail');
        Route::match(['post','get'],'upgrade-apply-match-pay')->uses('UpgradeController@applyMatchPay')->name('f_Wap_Upgrade_apply_match_pay');

        Route::match(['post','get'],'upgrade-apply-match-send-pay')->uses('UpgradeController@applyMatchSendPay')->name('f_Wap_Upgrade_apply_match_send_pay');


        Route::match(['post','get'],'upgrade-handle')->uses('UpgradeController@handleApply')->name('f_Wap_Upgrade_handle');

        Route::match(['post','get'],'upgrade-handle-record')->uses('UpgradeController@handleRecord')->name('f_Wap_Upgrade_handle_record');

        Route::match(['post','get'],'upgrade-match-speed')->uses('UpgradeController@matchSpeed')->name('f_Wap_Upgrade_match_speed');

        /*消息*/

        Route::match(['post','get'],'message-index')->uses('MessageController@index')->name('f_Wap_message_index');

        //添加留言(视图)
        Route::match(['get','post','option'],'/addMsg')->uses('MessageController@addMessage')->name('f_Wap_message-addMsg');

        //添加留言（执行）
        Route::match(['post','option'],'/add')->uses('MessageController@add')->name('f_Wap_message-add');

        //回复留言
        Route::match(['get','post','option'],'/reply')->uses('MessageController@reply')->name('f_Wap_message-reply');

        //删除留言
        Route::match(['get','post','option'],'/deleteMsg')->uses('MessageController@deleteMessage')->name('f_Wap_message-delete');

        //发送留言
        Route::match(['get','post','option'],'/send')->uses('MessageController@send')->name('f_Wap_message-send');

        //平台赠送
        Route::match(['get','post','option'],'/giveBonus')->uses('UserController@giveBonus')->name('f_Wap_user-giveBonus');


        Route::get('goldEgg')->uses('LotteryController@goldEgg')->name('f_wap_lottery_goldegg');
        Route::get('mywin')->uses('LotteryController@mywin')->name('f_wap_lottery_mywin');
        Route::match(['get','post','option'],'/zan')->uses('LotteryController@zan')->name('f_wap_lottery_zan');

    });

});


Route::namespace('Pc')->middleware('UserloginData')->group(function (){

    Route::get('goods/{zone?}')->uses('GoodsController@goodsList')->name('f_Pc_Goods_goodsList')->where('zone','1|2|3|4');

    Route::get('goods-detail-{goods_id}')->uses('GoodsController@goodsDetails')->name('f_Pc_Goods_goodsDetails')
        ->where('goods_id','[0-9]+');

    Route::match(['post','get'],'search')->uses('GoodsController@search')->name('f_Pc_Goods_search');

    Route::get('goods-tj')->uses('GoodsController@detailAdGoods')->name('f_Pc_Goods_detailAdGoods');

    Route::middleware('CheckUserLogin')->group(function (){

        /*地址管理*/
        Route::get('address')->uses('AddressController@myAddress')->name('f_Pc_Address_myAddress');
        Route::match(['post','get'],'address-add')->uses('AddressController@create')->name('f_Pc_Address_create');
        Route::match(['post','get'],'address-edit-{addr_id}')->uses('AddressController@update')->name('f_Pc_Address_update')
            ->where('addr_id','[0-9]+');

        Route::get('address-remove-{addr_id}')->uses('AddressController@delete')->name('f_Pc_Address_delete')
            ->where('addr_id','[0-9]+');

        Route::get('address-default-{addr_id}')->uses('AddressController@setDefault')->name('f_Pc_Address_setDefault')
            ->where('addr_id','[0-9]+');

        /*订单管理*/
        Route::post('goods-buy-{goods_id}')->uses('OrderController@buyNow')->name('f_Pc_Order_buyNow')
            ->where('goods_id','[0-9]+'); //立即购买

//        Route::post('cart-buy')->uses('OrderController@buyCart')->name('f_Pc_Order_buyCart'); //通过购物车购买

        Route::post('cart-buy/{zone?}')->uses('OrderController@buyCart')->name('f_Pc_Order_buyCart')
            ->where('zone','1|2|3|4');//通过购物车购买

        Route::post('order-create/{zone?}')->uses('OrderController@createOrder')->name('f_Pc_Order_createOrder')->where('zone','1|2|3|4'); //生成订单

        Route::match(['post','get'],'order-pay/{order_sn}')->uses('OrderController@orderPay')->name('f_Pc_Order_orderPay')
            ->where('order_sn','[A-Z0-9]+'); //支付订单

        Route::get('orders')->uses('OrderController@orderList')->name('f_Pc_Order_orderList');

        Route::get('order-remove/{order_sn}')->uses('OrderController@delete')->name('f_Pc_Order_delete')
            ->where('order_sn','[A-Z0-9]+'); //删除订单

        Route::get('order-cancel/{order_sn}')->uses('OrderController@cancel')->name('f_Pc_Order_cancel')
            ->where('order_sn','[A-Z0-9]+'); //删除订单

        Route::get('order-confirm/{order_sn}')->uses('OrderController@confirmOrder')->name('f_Pc_Order_confirmOrder')->where('order_sn','[A-Z0-9]+'); //确认订单;

        Route::get('order-detail')->uses('OrderController@detailOrder')->name('f_Pc_Order_detailOrder');

        /*会员管理*/
        Route::get('side-user')->uses('UserController@sideUser')->name('f_Pc_User_sideUser');


        /*购物车*/
//        Route::get('carts')->uses('CartController@cartList')->name('f_Pc_Cart_cartList');
        Route::get('cart/{zone?}')->uses('CartController@cartList')->name('f_Pc_Cart_cartList')
            ->where('zone','1|2|3|4');

        Route::get('async-carts')->uses('CartController@asyncGetCarts')->name('f_Pc_Cart_asyncGetCarts');

        Route::post('cart-add')->uses('CartController@create')->name('f_Pc_Cart_create');
        Route::post('cart-edit/{cart_id}')->uses('CartController@update')->name('f_Pc_Cart_update')
            ->where('cart_id','[0-9]+');

        Route::match(['post','get'],'cart-remove')->uses('CartController@delete')->name('f_Pc_Cart_delete');
        Route::get('cart-clear')->uses('CartController@clearAll')->name('f_Pc_Cart_clearAll');


        /*会员中心*/
        Route::get('coupon-grab')->uses('UserController@grabCoupon')->name('f_Pc_User_grabCoupon');

        Route::match(['post','get'],'user-wallet')->uses('UserController@myWallet')->name('f_Pc_User_Wallet');

    });


});
